<?php if (!defined('BASEPATH')) exit('No direct script access allowed.');

class MY_Form_validation extends CI_Form_validation
{
	/*
	 function valid_url($url) {
        if(preg_match("/^http(|s):\/{2}(.*)\.([a-z]){2,}(|\/)(.*)$/i", $url)) {
            if(filter_var($url, FILTER_VALIDATE_URL)) return TRUE;
        }
        $this->CI->form_validation->set_message('valid_url', 'The %s must be a valid URL.');
        return FALSE;
    }

  
    function alpha_extra($str) {
        $this->CI->form_validation->set_message('alpha_extra', 'The %s may only contain alpha-numeric characters, spaces, periods, underscores & dashes.');
        return ( ! preg_match("/^([\.\s-a-z0-9_-])+$/i", $str)) ? FALSE : TRUE;
    }

  
    function numeric_comma($str) {
        $this->CI->form_validation->set_message('numeric_comma', 'The %s may only contain numeric & comma characters.');
        return ( ! preg_match("/^(\d+,)*\d+$/", $str)) ? FALSE : TRUE;
    }

   
    function matches_pattern($str, $pattern) {
        if (preg_match('/^' . $pattern . '$/', $str)) return TRUE;
        $this->CI->form_validation->set_message('matches_pattern', 'The %s field does not match the required pattern.');
        return FALSE;
    }  
	
	function set_errors($fields)
   {
      if (is_array($fields) and count($fields))
      {
         foreach($fields as $key => $val)
         {
            $error = $key.'_error';
            if (isset($this->$error) and isset($this->$key) and $this->$error != '')
            {
               $old_error = $this->$error;
               $new_error = $this->_error_prefix.sprintf($val, $this->$key).$this->_error_suffix;
               $this->error_string = str_replace($old_error, $new_error, $this->error_string);
               $this->$error = $new_error;
            }
         }
      }     
   }*/
   
    function run($module = NULL, $group = '') {
        if (is_object($module)) $this->CI =& $module;
        return parent::run($group);
    }
}

/* End of file MY_Form_validation.php */
